home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 50
/
Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso
/
Aminet
/
util
/
wb
/
BWS_Scalos.lha
/
BWS_Scalos
/
Scalos_Rename
/
Rename.prefs.e
< prev
next >
Wrap
Text File
|
2001-12-06
|
14KB
|
494 lines
OPT PREPROCESS
OPT STACK=32000
MODULE 'muimaster','libraries/mui','afc/rexxer','afc/localer',
'update',
'*loc','*locnums','*other',
'amigaini','mui/betterstring_mcc','libraries/asl',
'amigainibase',
'amigalib/boopsi',
'tools/exceptions',
'utility/tagitem',
'utility/hooks',
'workbench/startup',
'tools/installhook'
DEF app=0,window,running=TRUE,comHook:hook,lo=0:PTR TO localer,loclang,
verN, verS, str[500]:STRING,up=0:PTR TO updObject,
deftitle, save,use,ref,quit,prefsfile[256]:STRING,
strpaths=0,listformat[100]:STRING,listtitle=1,listshow=1,highlight=1,
popS=1,showlabel=1,textmode=3,onret=0,myname,
prefBU=0:PTR TO LONG,updB,prfS,prfF,prfpf,
shtL=1,shnL=1,shpL=1,siT=1,snT=1,guide,ai=0:PTR TO amigaini,
spC,hiC,puC,onrC,lsC,ltC,shtC,shnC,shpC,slC,sliC,slnC
PROC main() HANDLE
DEF sigs=0, result,wb:PTR TO wbstartup, args:PTR TO wbarg
deftitle:='Scalos_Rename Prefs'
verN:='40.9'
verS:='$VER: Scalos_Rename Prefs 40.9 (06.12.2001)'
lo:=startlocale(lo)
loclang:=lo.language()
IF (muimasterbase:=OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN))=NIL THEN
Raise(failedOpen('muimaster.library'))
IF (amigainibase:=OpenLibrary(AMIGAINI_NAME,AMIGAINI_VMIN))=NIL THEN
Raise(failedOpen('amigaini.library'))
installhook(comHook,{comFunc})
IF wbmessage=NIL
myname:=getprogname()
ELSE /* from wb */
wb:=wbmessage
args:=wb.arglist
NameFromLock(args[0].lock,str,256)
IF StrLen(args[0].name)>0 THEN AddPart(str, args[0].name,256)
myname:=news(str)
ENDIF
loadsettings()
guide:='Scalos:Docs/Scalos_Rename.guide'
IF FileLength(guide)<1 THEN guide:='help:Scalos_Rename.guide' ELSE JUMP gotguide
IF FileLength(guide)>1 THEN JUMP gotguide
guide:=0
gotguide:
app:=ApplicationObject,
MUIA_Application_Title , deftitle,
MUIA_Application_Version , verS,
MUIA_Application_Copyright , '©2000/2002, Bruce Steers',
MUIA_Application_Author , 'Bruce Steers',
MUIA_Application_Description, 'Rename Prefs Module for Scalos',
MUIA_Application_Base , 'SCALOS_RENAME_PREFS',
MUIA_Application_HelpFile , guide,
SubWindow, window:= WindowObject,
MUIA_Window_Title , 'Rename Prefs',
MUIA_Window_ScreenTitle , deftitle,
MUIA_Window_ID , "MAIN",
MUIA_Window_AppWindow, MUI_TRUE,
WindowContents, VGroup,
Child, ScrollgroupObject,
MUIA_Scrollgroup_Contents, VirtgroupObject,
VirtualFrame,
Child, VGroup,
GroupFrame,
MUIA_FrameTitle,locs(lo,MSG_InfoLab),
Child, HGroup,
Child, RectangleObject, End,
Child, Label(locs(lo,MSG_ShowLab)),
Child, slC:=CheckMark(Abs(textmode>0)),
Child, RectangleObject, End,
End,
Child, VGroup,
GroupFrame,
MUIA_FrameTitle,locs(lo,MSG_LabItems),
Child, HGroup,
Child, RectangleObject, End,
Child, Label(locs(lo,MSG_ShowType)),
Child, sliC:=CheckMark(siT),
Child, RectangleObject, End,
End,
Child, HGroup,
Child, RectangleObject, End,
Child, Label(locs(lo,MSG_ShowName)),
Child, slnC:=CheckMark(snT),
Child, RectangleObject, End,
End,
End,
End,
Child, ColGroup(4),
GroupFrame,
MUIA_FrameTitle,locs(lo,MSG_StringGad),
Child, RectangleObject, End,
Child, Label(locs(lo,MSG_StrPaths)),
Child, spC:=CheckMark(strpaths),
Child, RectangleObject, End,
->End,
->Child, HGroup,
Child, RectangleObject, End,
Child, Label(locs(lo,MSG_ShowPop)),
Child, puC:=CheckMark(popS),
Child, RectangleObject, End,
->End,
->Child, HGroup,
Child, RectangleObject, End,
Child, Label(locs(lo,MSG_Highlight)),
Child, hiC:=CheckMark(highlight),
Child, RectangleObject, End,
->End,
->Child, HGroup,
Child, RectangleObject, End,
Child, Label(locs(lo,MSG_OnReturn)),
Child, onrC:=CheckMark(onret),
Child, RectangleObject, End,
->End,
End,
Child, VGroup,
GroupFrame,
MUIA_FrameTitle,locs(lo,MSG_QueueList),
Child, HGroup,
Child, RectangleObject, End,
Child, Label(locs(lo,MSG_ShowQueue)),
Child, lsC:=CheckMark(listshow),
Child, RectangleObject, End,
End,
Child, HGroup,
Child, RectangleObject, End,
Child, Label(locs(lo,MSG_ShowTitles)),
Child, ltC:=CheckMark(listtitle),
Child, RectangleObject, End,
End,
Child, VGroup,
GroupFrame,
MUIA_FrameTitle,locs(lo,MSG_ListColumns),
Child, HGroup,
Child, RectangleObject, End,
Child, Label(locs(lo,MSG_ShowType)),
Child, shtC:=CheckMark(shtL),
Child, RectangleObject, End,
End,
Child, HGroup,
Child, RectangleObject, End,
Child, Label(locs(lo,MSG_ShowName)),
Child, shnC:=CheckMark(shnL),
Child, RectangleObject, End,
End,
Child, HGroup,
Child, RectangleObject, End,
Child, Label(locs(lo,MSG_ShowPath)),
Child, shpC:=CheckMark(shpL),
Child, RectangleObject, End,
End,
End,
End,
Child, HGroup,
Child, Label2('MyName'),
Child, PopaslObject,
MUIA_Popstring_String, prfS := BetterStringObject,
StringFrame,
MUIA_String_Contents,prefsfile,
MUIA_CycleChain,1,
End,
MUIA_Popstring_Button, prfpf := PopButton(MUII_PopFile),
ASLFR_TITLETEXT, 'Select Prefs Editor...',
End,
Child, prfF:=SimpleButton('Get'),
End,
End,
End,
Child, HGroup,
GroupFrame,
Child, save:=SimpleButton(locs(lo,GAD_Save)),
Child, use:=SimpleButton(locs(lo,GAD_Use)),
End,
Child, ref:=SimpleButton(locs(lo,GAD_Refresh)),
Child, updB:=SimpleButton(locs(lo,GAD_Update)),
Child, quit:=SimpleButton(locs(lo,GAD_Ignore)),
End,
End,
End
IF (app=NIL) THEN Raise(locs(lo,MSG_NoApp))
doMethodA(app,[MUIM_MultiSet,MUIA_Weight,0,prfF,0])
doMethodA(window,[MUIM_Notify,MUIA_Window_CloseRequest,MUI_TRUE,
app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit])
doMethodA(quit,[MUIM_Notify,MUIA_Pressed,0,
app,2,MUIM_Application_ReturnID,"canc"])
doMethodA(prfF,[MUIM_Notify,MUIA_Pressed,0,
prfS,3,MUIM_Set,MUIA_String_Contents,myname])
doMethodA(ref,[MUIM_Notify,MUIA_Pressed,0,
app,2,MUIM_Application_ReturnID,"ref"])
doMethodA(updB,[MUIM_Notify,MUIA_Pressed,0,
app,2,MUIM_Application_ReturnID,"upd"])
doMethodA(save,[MUIM_Notify,MUIA_Pressed,0,
app,2,MUIM_Application_ReturnID,"save"])
doMethodA(use,[MUIM_Notify,MUIA_Pressed,0,
app,2,MUIM_Application_ReturnID,"use"])
doMethodA(spC,[MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
app,4,MUIM_CallHook,comHook,"sp",MUIV_TriggerValue])
doMethodA(hiC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
app,4,MUIM_CallHook,comHook,"hi",MUIV_TriggerValue])
doMethodA(puC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
app,4,MUIM_CallHook,comHook,"pop",MUIV_TriggerValue])
doMethodA(onrC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
app,3,MUIM_WriteLong,MUIV_TriggerValue,{onret}])
doMethodA(slC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
app,4,MUIM_CallHook,comHook,"sl",MUIV_TriggerValue])
doMethodA(sliC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
app,4,MUIM_CallHook,comHook,"slI",MUIV_TriggerValue])
doMethodA(slnC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
app,4,MUIM_CallHook,comHook,"slN",MUIV_TriggerValue])
doMethodA(lsC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
app,4,MUIM_CallHook,comHook,"shoL",MUIV_TriggerValue])
doMethodA(ltC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
app,3,MUIM_WriteLong,MUIV_TriggerValue,{listtitle}])
doMethodA(shtC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
app,4,MUIM_CallHook,comHook,"shT",MUIV_TriggerValue])
doMethodA(shnC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
app,4,MUIM_CallHook,comHook,"shN",MUIV_TriggerValue])
doMethodA(shpC, [MUIM_Notify,MUIA_Selected,MUIV_EveryTime,
app,4,MUIM_CallHook,comHook,"shP",MUIV_TriggerValue])
set(puC,MUIA_Disabled,Abs(strpaths=0))
doMethodA(app,[MUIM_MultiSet,MUIA_Disabled,Abs(showlabel=0),slnC,sliC,0])
doMethodA(app,[MUIM_MultiSet,MUIA_Disabled,Abs(listshow=0),shpC,shnC,shtC,ltC,0])
up:=NEW [app,
window,
'Scalos_Rename',
deftitle,
verS,
locs(lo,MSG_chk),
locs(lo,MSG_YesNo),
locs(lo,MSG_Open),
locs(lo,MSG_unfound),
locs(lo,MSG_latest),
locs(lo,MSG_better),
locs(lo,MSG_found),
locs(lo,MSG_NewVerGads),
locs(lo,MSG_aborted),
locs(lo,MSG_UpdError),
locs(lo,MSG_complete)]:updObject
set(window,MUIA_Window_Open,MUI_TRUE)
WHILE running
result:=doMethodA(app,[MUIM_Application_NewInput,{sigs}])
SELECT result
CASE MUIV_Application_ReturnID_Quit; compareprefs() ;running:=0
CASE "save";writeprefs(1,1); running:=0
CASE "use"; writeprefs(0,1); running:=0
CASE "ref"; writeprefs(0,1);
CASE "canc"; running:=0
CASE "upd"; update(up)
ENDSELECT
IF (running AND sigs) THEN sigs:=Wait(sigs)
ENDWHILE
IF result<>-5 THEN compareprefs()
EXCEPT DO
IF exception THEN muireq(deftitle,StringF(str,'\s !\n\s',locs(lo,MSG_EXCEPT),exception),'_OK',app,0)
IF app THEN Mui_DisposeObject(app)
IF amigainibase THEN CloseLibrary(amigainibase)
IF muimasterbase THEN CloseLibrary(muimasterbase)
IF up THEN END up
IF lo THEN END lo
ENDPROC
PROC loadsettings()
NEW ai
Ini_Init(ai,'ENV:Scalos/Rename.ini')
Ini_Read(ai)
IF ai.error
Ini_NewGroup(ai,'Misc Options')
Ini_NewGroup(ai,'Text Options')
Ini_NewGroup(ai,'String Options')
Ini_NewGroup(ai,'List Options')
ENDIF
Ini_FindGroup(ai,'[Misc Options]')
StringF(prefsfile,'\s',Ini_GetStr(ai,'PREFSFILE','Scalos:Prefs/Modules/Rename.prefs'))
Ini_FindGroup(ai,'Text Options')
showlabel:=Ini_GetInt(ai,'TEXTSHOW',1)
textmode:=Ini_GetInt(ai,'TEXTMODE',3)
Ini_FindGroup(ai,'[String Options]')
strpaths:=Ini_GetInt(ai,'STRINGPATHS',0)
highlight:=Ini_GetInt(ai,'HIGHLIGHT',1)
popS:=Ini_GetInt(ai,'POPFILE',1)
onret:=Ini_GetInt(ai,'ONRETURN',0)
Ini_FindGroup(ai,'[List Options]')
StringF(listformat,'\s',Ini_GetStr(ai,'LISTFORMAT','COL=0 BAR,COL=1 BAR,COL=2'))
listtitle:=Ini_GetInt(ai,'LISTTITLE=',1)
listshow:=Ini_GetInt(ai,'LISTSHOW',1)
processformatstr(listformat)
gettextmode()
backupprefs()
ENDPROC
PROC backupprefs(); DEF c
IF prefBU THEN DisposeLink(prefBU)
prefBU:=List(ai.length)
FOR c:=0 TO ai.length-1 DO ListAdd(prefBU,[news(ai.list[c])])
ENDPROC
PROC buildformatstr(); DEF s[50]:STRING
IF shtL THEN StrAdd(s,'COL=0')
IF shnL THEN StrAdd(s,IF StrLen(s)>0 THEN ' BAR,COL=1' ELSE 'COL=1')
IF shpL THEN StrAdd(s,IF StrLen(s)>0 THEN ' BAR,COL=2' ELSE 'COL=2')
StringF(listformat,'\s',s)
ENDPROC
PROC processformatstr(fs)
shtL:=Abs(InStr(fs,'COL=0')<>-1)
shnL:=Abs(InStr(fs,'COL=1')<>-1)
shpL:=Abs(InStr(fs,'COL=2')<>-1)
ENDPROC
PROC compareprefs(); DEF mode,changed=0
prefs2ini()
FOR mode:=0 TO Min(ListLen(prefBU),ListLen(ai.list))-1 DO IF StrCmp(prefBU[mode],ai.list[mode])=0 THEN changed:=1
IF changed=0 THEN RETURN
mode:=muireq(deftitle,locs(lo,MSG_PrefChange),StringF(str,'\s|\s|\s',locs(lo,GAD_Save),locs(lo,GAD_Use),locs(lo,GAD_Ignore)),app,window)
IF mode=0 THEN RETURN
writeprefs(mode)
ENDPROC
PROC writeprefs(arcmode,doini=0)
IF doini THEN prefs2ini()
Ini_Write(ai)
IF arcmode=1
ai.filename:='ENVARC:Scalos/Rename.ini'
Ini_Write(ai)
ai.filename:='ENV:Scalos/Rename.ini'
ENDIF
backupprefs()
updateopenguis()
ENDPROC
PROC prefs2ini()
Ini_FindGroup(ai,'[Text Options]')
settextmode()
Ini_SetInt(ai,'TEXTSHOW',showlabel)
Ini_SetInt(ai,'TEXTMODE',textmode)
Ini_FindGroup(ai,'[String Options]')
Ini_SetInt(ai,'STRINGPATHS',strpaths)
Ini_SetInt(ai,'HIGHLIGHT',highlight)
Ini_SetInt(ai,'POPFILE',popS)
Ini_SetInt(ai,'ONRETURN',onret)
Ini_FindGroup(ai,'[List Options]')
Ini_SetStr(ai,'LISTFORMAT',listformat)
Ini_SetInt(ai,'LISTTITLE',listtitle)
Ini_SetInt(ai,'LISTSHOW',listshow)
ENDPROC
PROC failedOpen(name); DEF msg[256]:STRING; StringF(msg,'\s \s',locs(lo,MSG_Open),name); ENDPROC msg
PROC comFunc(d:PTR TO LONG); DEF a
a:=d[]
SELECT a
CASE "pop"; popS:=d[1]
CASE "sp"; strpaths:=d[1]; set(puC,MUIA_Disabled,Abs(strpaths=0))
CASE "hi"; highlight:=d[1]
CASE "slI"; siT:=d[1]; settextmode(); reftextmode()
CASE "slN"; snT:=d[1]; settextmode(); reftextmode()
CASE "sl"; showlabel:=d[1];
doMethodA(app,[MUIM_MultiSet,MUIA_Disabled,Abs(showlabel=0),slnC,sliC,0])
IF (showlabel) AND (snT=0) AND (siT=0) THEN
doMethodA(app,[MUIM_MultiSet,MUIA_Selected,1,slnC,sliC,0])
CASE "shoL"; listshow:=d[1];
doMethodA(app,[MUIM_MultiSet,MUIA_Disabled,Abs(listshow=0),shpC,shnC,shtC,ltC,0])
IF (listshow) AND (shtL=0) AND (shnL=0) AND (shpL=0) THEN
doMethodA(app,[MUIM_MultiSet,MUIA_Selected,1,shtC,shnC,shpC,0])
CASE "shT"; shtL:=d[1]; buildformatstr(); refformatstr()
CASE "shN"; shnL:=d[1]; buildformatstr(); refformatstr()
CASE "shP"; shpL:=d[1]; buildformatstr(); refformatstr()
ENDSELECT
ENDPROC
PROC settextmode()
textmode:=0
IF siT THEN textmode:=1
IF snT THEN textmode:=textmode+2
ENDPROC
PROC gettextmode()
siT:=Abs(Odd(textmode))
snT:=Abs(textmode>=2)
ENDPROC
PROC reftextmode()
set(slC,MUIA_Selected,Abs(textmode>0))
ENDPROC
PROC refformatstr()
set(lsC,MUIA_Selected,Abs(StrLen(listformat)>0))
ENDPROC
PROC updateopenguis(); DEF c,rx=NIL:PTR TO rexxer
NEW rx.rexxer('RENAME_SENDER')
FOR c:=1 TO 10
StringF(str,'SCALOS_RENAME.\d',c)
IF FindPort(str)
rx.send(str, 'SETPREFS')
ENDIF
ENDFOR
END rx
ENDPROC
PROC getprogname(); DEF l,d,f[56]:STRING
IF l:=GetProgramDir()
d:=String(256)
NameFromLock(l,d,256)
GetProgramName(f,56)
AddPart(d,f,256)
SetStr(d,StrLen(d))
ENDIF
ENDPROC d